﻿Imports CustomTshirtFinal

Public Class Pedidos

    Private Sub btnNuevo_Click(sender As System.Object, e As System.EventArgs) Handles btnNuevo.Click
        Dim form As New PedidoNuevo
        form.MdiParent = Me.MdiParent
        form.Pedidos = Me
        form.Show()
    End Sub

    Private Sub btnBuscar_Click(sender As System.Object, e As System.EventArgs) Handles btnBuscar.Click

        Dim criterio As String = Me.txtBuscar.Text

        Dim negocio As New PedidoNegocio
        Dim pedido As Collection = negocio.buscarPorFecha(criterio)
        Me.dgvPedidos.DataSource = pedido
        Me.dgvPedidos.EditMode = False

        Me.dgvPedidos.Columns(0).HeaderText = "Id Pedido"
        Me.dgvPedidos.Columns(1).HeaderText = "Id Usuario"
        Me.dgvPedidos.Columns(2).HeaderText = "Fecha"
        Me.dgvPedidos.Columns(3).HeaderText = "Estado"
        Me.dgvPedidos.Columns(4).HeaderText = "Total"


    End Sub

    Private Sub Pedidos_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load

        With Me.dgvPedidos.ColumnHeadersDefaultCellStyle
            .BackColor = Color.Green
            .ForeColor = Color.DarkGreen

        End With

    End Sub

    Private Sub btnEditar_Click(sender As System.Object, e As System.EventArgs) Handles btnEditar.Click
        Dim selecionado = Me.dgvPedidos.CurrentRow.Cells(0).Value.ToString

        Dim form As New PedidoNuevo
        form.MdiParent = Me.MdiParent
        form.lblId.Text = selecionado
        form.Pedidos = Me
        form.Show()

    End Sub

    Private Sub btnEliminar_Click(sender As System.Object, e As System.EventArgs) Handles btnEliminar.Click
        Dim seleccionado = Me.dgvPedidos.CurrentRow.Cells(0).Value.ToString
        Dim negocio As New PedidoNegocio
        negocio.eliminar(seleccionado)
        dgvPedidos.DataSource = ""
    End Sub
End Class